package com.yangtzeu.jwc.activity;

import android.R.anim;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.yangtzeu.jwc.utils.AllActivitys;
import com.zhangdi.jwc.R;
import com.zjsx.lib.utils.T;

public class BaseActivity extends ActionBarActivity implements OnClickListener {
    AllActivitys activitys;

    View titleView;

    TextView tvLogo;
    TextView tvTitleLeft;
    TextView tvTitle;
    TextView tvTitleRight;
    TextView tvTitleRight2;
    ProgressBar pb_loading;
    ImageButton ib_option;
    View logline;
    
    LinearLayout logoLayout;
    
    Handler handler;
    
    ActionBar actionBar;
    

    @Override
    protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) { 
	    getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); 
	    getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
	}
	activitys = AllActivitys.getInstance();
	activitys.onCreate(this);

	handler = new Handler(){
	    @Override
	    public void handleMessage(Message msg) {
	        handleMsg(msg);
	    }
	};
	
	setView();
	actionBar = getSupportActionBar();
	actionBar.setDisplayHomeAsUpEnabled(true);
	initData();
	initActionBar();
	initView();
	initListener();
	initAdapter();
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
	if(item.getItemId() == android.R.id.home){
	    this.finish();
	}
	return super.onOptionsItemSelected(item);
    }
    
    @SuppressLint("InflateParams")
    protected void setSimpleActionBar(String logoText, String leftTitleText, String titleText, String rightTitleText) {
	
    }

    public void setActionBarLayout(View view) {
	
    }

    public void setView() {

    }

    public void initData() {

    }

    public void initActionBar() {
	setSimpleActionBar(null, null, "长江大学教务处", null);
    }

    public void initView() {

    }

    public void initListener() {

    }

    public void initAdapter() {

    }

    @Override
    public void onClick(View v) {
	switch (v.getId()) {
	case R.id.ib_logo:
	    finish();
	    break;
	case R.id.ll_logo:
	    finish();
	    break;
	default:
	    break;
	}
    }

    public void handleMsg(Message msg){
	
    }
    
    @Override
    protected void onDestroy() {
	super.onDestroy();
	activitys.onDestroy(this);
    }

    @Override
    protected void onPause() {
	super.onPause();
	activitys.onPause(this);
    }

    @Override
    protected void onResume() {
	super.onResume();
	activitys.onResume(this);
    }

}
